package com.illtamer.infinite.sillage.service;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.illtamer.infinite.sillage.mapper.TypeMapper;
import com.illtamer.infinite.sillage.pojo.Type;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TypeService extends BaseMapperService<Type> {

    @Autowired
    public TypeService(BaseMapper<Type> mapper) {
        super(mapper);
    }

    @Transactional(rollbackFor = Exception.class)
    public List<Type> listThinTypes() {
        return ((TypeMapper) mapper).listThinTypes();
    }

    @Transactional(rollbackFor = Exception.class)
    public Page<Type> listThinTypes(int currentPage, int limit) {
        return ((TypeMapper) mapper).listThinTypes(new Page<>(currentPage, limit));
    }

    @Deprecated
    @Override
    public Page<Type> listEntities(int currentPage, int limit) {
        throw new UnsupportedOperationException("Please use #listTypes");
    }

}
